package org.yinweichen.llm_dataset_backend.repository;

import org.yinweichen.llm_dataset_backend.entity.QuestionTag;
import org.yinweichen.llm_dataset_backend.entity.QuestionTagId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface QuestionTagRepository extends JpaRepository<QuestionTag, QuestionTagId> {
    void deleteByIdAndVersionAndTag(Long id, String version, String tag);

    @Query("SELECT DISTINCT qt.tag FROM QuestionTag qt")
    List<String> findAllDistinctTags();

    @Query("SELECT qt.tag FROM QuestionTag qt WHERE qt.id = :questionId AND qt.version = :version")
    List<String> findTagsByQuestionIdAndVersion(Long questionId, String version);
}
